Sets our main struct and passes it to the parent class.
Creates a new source buffer.
Creates a new source buffer using the highlighting patterns in language.
@iter is set to a valid iterator pointing to the matching bracket if @state is %GTK_SOURCE_BRACKET_MATCH_FOUND. Otherwise @iter is meaningless.
The "cursor-moved" signal is emitted when then insertion mark has moved.
The ::highlight-updated signal is emitted when the syntax highlighting and context classes are updated in a certain region of the @buffer.
The ::source-mark-updated signal is emitted each time a mark is added to, moved or removed from the @buffer.
Moves iter to the position of the previous [class@Mark] of the given category.
Changes the case of the text between the specified iterators.
Creates a source mark in the buffer of category category.
Forces buffer to analyze and highlight the given area synchronously.
Moves iter to the position of the next [class@Mark] of the given category.
Get the main Gtk struct
Get all defined context classes at @iter.
Determines whether bracket match highlighting is activated for the source buffer.
Determines whether syntax highlighting is activated in the source buffer.
Returns the [class@Language] associated with the buffer, see [method@Buffer.set_language].
Returns the list of marks of the given category at @iter.
Returns the list of marks of the given category at @line.
the main Gtk struct as a void*
Returns the [class@StyleScheme] associated with the buffer, see [method@Buffer.set_style_scheme].
Moves backward to the next toggle (on or off) of the context class.
Moves forward to the next toggle (on or off) of the context class.
Check if the class @context_class is set on @iter.
Joins the lines of text between the specified iterators.
Remove all marks of @category between @start and @end from the buffer.
Controls the bracket match highlighting function in the buffer.
Controls whether syntax is highlighted in the buffer.
Sets whether the @buffer has an implicit trailing newline.
Associates a [class@Language] with the buffer.
Sets a [class@StyleScheme] to be used by the buffer and the view.
Sort the lines of text between the specified iterators.
the main Gtk struct
the main Gtk struct
Get the main Gtk struct
the main Gtk struct as a void*
Inserts text into buffer at iter, applying the list of tags to the newly-inserted text. The last tag specified must be NULL to terminate the list. Equivalent to calling gtk_text_buffer_insert(), then gtk_text_buffer_apply_tag() on the inserted text; gtk_text_buffer_insert_with_tags() is just a convenience function.
Same as gtk_text_buffer_insert_with_tags(), but allows you to pass in tag names instead of tag objects.
Creates a tag and adds it to the tag table for buffer. Equivalent to adding a new tag to the buffer's tag table.
Obtain the entire text
Adds the mark at position @where.
Adds @clipboard to the list of clipboards in which the selection contents of @buffer are available.
Emits the “apply-tag” signal on @buffer.
Emits the “apply-tag” signal on @buffer.
Performs the appropriate action as if the user hit the delete key with the cursor at the position specified by @iter.
Denotes the beginning of an action that may not be undone.
Called to indicate that the buffer operations between here and a call to gtk_text_buffer_end_user_action() are part of a single user-visible operation.
Copies the currently-selected text to a clipboard.
Creates and inserts a child anchor.
Creates a mark at position @where.
Copies the currently-selected text to a clipboard, then deletes said text if it’s editable.
Deletes text between @start and @end.
Deletes all editable text in the given range.
Deletes @mark, so that it’s no longer located anywhere in the buffer.
Deletes the mark named @name; the mark must exist.
Deletes the range between the “insert” and “selection_bound” marks, that is, the currently-selected text.
Denotes the end of an action that may not be undone.
Ends a user-visible operation.
Retrieves the first and last iterators in the buffer, i.e. the entire buffer lies within the range [@start,@end).
Gets whether there is a redoable action in the history.
Gets whether there is an undoable action in the history.
Gets the number of characters in the buffer.
Gets whether the buffer is saving modifications to the buffer to allow for undo and redo actions.
Initializes @iter with the “end iterator,” one past the last valid character in the text buffer.
Indicates whether the buffer has some text currently selected.
Returns the mark that represents the cursor (insertion point).
Obtains the location of @anchor within @buffer.
Initializes @iter to the start of the given line.
Obtains an iterator pointing to @byte_index within the given line.
Obtains an iterator pointing to @char_offset within the given line.
Initializes @iter with the current position of @mark.
Initializes @iter to a position @char_offset chars from the start of the entire buffer.
Obtains the number of lines in the buffer.
Returns the mark named @name in buffer @buffer, or %NULL if no such mark exists in the buffer.
Gets the maximum number of undo levels to perform.
Indicates whether the buffer has been modified since the last call to [method@Gtk.TextBuffer.set_modified] set the modification flag to %FALSE.
Returns the mark that represents the selection bound.
Returns %TRUE if some text is selected; places the bounds of the selection in @start and @end.
Get a content provider for this buffer.
Returns the text in the range [@start,@end).
Initialized @iter with the first position in the text buffer.
Get the GtkTextTagTable associated with this buffer.
Returns the text in the range [@start,@end).
Inserts @len bytes of @text at position @iter.
Inserts @text in @buffer.
Inserts a child widget anchor into the text buffer at @iter.
Inserts @text in @buffer.
Inserts @text in @buffer.
Inserts the text in @markup at position @iter.
Inserts an image into the text buffer at @iter.
Copies text, tags, and paintables between @start and @end and inserts the copy at @iter.
Copies text, tags, and paintables between @start and @end and inserts the copy at @iter.
Moves @mark to the new location @where.
Moves the mark named @name (which must exist) to location @where.
Pastes the contents of a clipboard.
This function moves the “insert” and “selection_bound” marks simultaneously.
Redoes the next redoable action on the buffer, if there is one.
Removes all tags in the range between @start and @end.
Removes a GdkClipboard added with gtk_text_buffer_add_selection_clipboard().
Emits the “remove-tag” signal.
Emits the “remove-tag” signal.
This function moves the “insert” and “selection_bound” marks simultaneously.
Sets whether or not to enable undoable actions in the text buffer.
Sets the maximum number of undo levels to perform.
Used to keep track of whether the buffer has been modified since the last time it was saved.
Deletes current contents of @buffer, and inserts @text instead.
Undoes the last undoable action on the buffer, if there is one.
Emitted to apply a tag to a range of text in a GtkTextBuffer.
Emitted at the beginning of a single user-visible operation on a GtkTextBuffer.
Emitted when the content of a GtkTextBuffer has changed.
Emitted to delete a range from a GtkTextBuffer.
Emitted at the end of a single user-visible operation on the GtkTextBuffer.
Emitted to insert a GtkTextChildAnchor in a GtkTextBuffer.
Emitted to insert a GdkPaintable in a GtkTextBuffer.
Emitted to insert text in a GtkTextBuffer.
Emitted as notification after a GtkTextMark is deleted.
Emitted as notification after a GtkTextMark is set.
Emitted when the modified bit of a GtkTextBuffer flips.
Emitted after paste operation has been completed.
Emitted when a request has been made to redo the previously undone operation.
Emitted to remove all occurrences of @tag from a range of text in a GtkTextBuffer.
Emitted when a request has been made to undo the previous operation or set of operations that have been grouped together.
Subclass of [class@Gtk.TextBuffer].
A GtkSourceBuffer object is the model for [class@View] widgets. It extends the [class@Gtk.TextBuffer] class by adding features useful to display and edit source code such as syntax highlighting and bracket matching.
To create a GtkSourceBuffer use [ctor@GtkSource.Buffer.new] or [ctor@GtkSource.Buffer.new_with_language]. The second form is just a convenience function which allows you to initially set a [class@Language]. You can also directly create a [class@View] and get its [class@Buffer] with [method@Gtk.TextView.get_buffer].
The highlighting is enabled by default, but you can disable it with [method@Buffer.set_highlight_syntax].
Context Classes:
It is possible to retrieve some information from the syntax highlighting engine. The default context classes that are applied to regions of a GtkSourceBuffer:
- **comment**: the region delimits a comment; - **no-spell-check**: the region should not be spell checked; - **path**: the region delimits a path to a file; - **string**: the region delimits a string.
Custom language definition files can create their own context classes, since the functions like [method@Buffer.iter_has_context_class] take a string parameter as the context class.
GtkSourceBuffer provides an API to access the context classes: [method@Buffer.iter_has_context_class], [method@Buffer.get_context_classes_at_iter], [method@Buffer.iter_forward_to_context_class_toggle] and [method@Buffer.iter_backward_to_context_class_toggle].
And the [signal@GtkSource.Buffer::highlight-updated] signal permits to be notified when a context class region changes.
Each context class has also an associated [class@Gtk.TextTag] with the name gtksourceview:context-classes:<name>. For example to retrieve the [class@Gtk.TextTag] for the string context class, one can write:
GtkTextTagTable *tag_table; GtkTextTag *tag; tag_table = gtk_text_buffer_get_tag_table (buffer); tag = gtk_text_tag_table_lookup (tag_table, "gtksourceview:context-classes:string");
The tag must be used for read-only purposes.
Accessing a context class via the associated [class@Gtk.TextTag] is less convenient than the GtkSourceBuffer API, because:
- The tag doesn't always exist, you need to listen to the [signal@Gtk.TextTagTable::tag-added] and [signal@Gtk.TextTagTable::tag-removed] signals. - Instead of the [signal@GtkSource.Buffer::highlight-updated] signal, you can listen to the [signal@Gtk.TextBuffer::apply-tag] and [signal@Gtk.TextBuffer::remove-tag] signals.
A possible use-case for accessing a context class via the associated [class@Gtk.TextTag] is to read the region but without adding a hard dependency on the GtkSourceView library (for example for a spell-checking library that wants to read the no-spell-check region).